﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dbPoll_Application.ViewModels.QuestionViewModel>" %>
<%@ Import Namespace="dbPoll_Application.Helpers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <div class="pageHeadingContainer"><h2 class="pageHeading">Questions</h2></div>
    <div id="contentContainer">
    <p><%= Html.ActionLink("Polls > ", "Index", "Poll", null, new { @class = "breadcrumb" })%><%= Model.pollName %></p>
    <table class="questions">
    <thead>
    <tr>
    <th class="questionNumberCol"></th>
    <th class="questionCol">Question</th>
    <th class="questionTypeCol">Type</th>
    <th class="questionDelCol"></th>
    </tr>
    </thead>
    <% foreach (var question in Model.questions)
       { %>
    <tr id="questionRow<%= question.questionID %>">
    <td><%= question.questionNumber %></td>
    <td class="questionCol"><span><%= question.question.CropAndTrail(60, "...") %></span></td>
    <td class="questionTypeCol"><%= (question.type == dbPoll_Application.Models.QuestionType.Alphanumeric || question.type == dbPoll_Application.Models.QuestionType.Numeric) ? "Short-Answer" : "Multiple-Choice"%></td>
    <td class="questionDelCol"><input type="button" value="Select" id="questionDel<%= question.questionID %>" class="questionDel"/></td>
    </tr>
    <% } %>
    </table>
    <% if (User.IsInRole("Poll Creator")) { %>
    <% using (Html.BeginForm("EditCustom", "Question", new { questionID = -1, questionNumber = Model.questions.Count + 1 }, FormMethod.Post, new { @id = "SAQForm" }))
       { %>
    <% Html.ValidationSummary(true); %>
    <input type="hidden" value="<%= Model.pollID %>" id="Hidden1" name="pollID"/>
    <input type="submit" value="Create Question" />
    <% } %>
    <% } %>
    </div>
</asp:Content>